<%
/*

Parameter
    $0 (first parameter):  path of Previous page
    $1 (second parameter): path of Next page
    $2 (third parameter): path to main menu of module

Issue
    * Problem of Apostrophe (https://developer.mozilla.org/fr/docs/JavaScript_Guide/Op%C3%A9rateurs/Op%C3%A9rateurs_sp%C3%A9ciaux)

*/

var lang = env.locale;
var strPrevious = "";
var strNext = "";
var strMenu = "";

var s_PreviousNext = mdn.localString({
    "en-US": [" Previous ",          " Next  "],
    "cs"   : [" Předchozí ",  " Následující  "],
    "de"   : [" zurück ",          " weiter  "],
    "es"   : [" Anterior ",     " Siguiente  "],
    "fr"   : [" Précédent ",      " Suivant  "],
    "pl"   : [" Poprzedni ",     " Następny  "],
    "pt-PT": [" Anterior ",       " Próxima  "],
    "pt-BR": [" Anterior ",       " Próxima  "],

    "he"   : [" קוד ם",                               "הבא "] ,
    "ja"   : [" 前のページ ",                        " 次のページ  "],
    "ko"   : [" 이전 ",                              " 다음  "],
    "ru"   : [" Назад ", " Далее  "],
    "zh-CN": [" 上一页 ",                            " 下一页  "],
    "zh-TW": [" 前頁 ",                              " 次頁  "]
});

var s_Menu = mdn.localString({
    "en-US": " Overview: ",
    "pt-BR": " Menu: ",
    "fr"   : " Aperçu&nbsp;: ",
    "ru"   : " Обзор: ",
    "de"   : " Übersicht: "
});

if ($0) {
    strPrevious = '<li><a class="button secondary" href="/' + lang + '/docs/' + $0.replace(/ /g, '_') + '"><span class="button-wrap">' + s_PreviousNext[0] + '</span></a></li>';
}

if ($1) {
    strNext = '<li><a class="button secondary" href="/' + lang + '/docs/' + $1.replace(/ /g, '_') + '"><span class="button-wrap">' + s_PreviousNext[1] + '</span></a></li>';
}

if ($2) {
  var startString = $2;
  var linkTextArray = startString.split('/');
  var linkText = linkTextArray[linkTextArray.length-1];
  var re = /_/gi;
  var finalString = linkText.replace(re,' ');

  if($0 && $1) {
    strMenu = '<li><a class="button secondary" href="/' + lang + '/docs/' + $2.replace(/ /g, '_') + '"><span class="button-wrap">' + s_Menu + finalString + '</span></a></li>';
  } else if($0) {
    strMenu = '<li><a class="button secondary" href="/' + lang + '/docs/' + $2.replace(/ /g, '_') + '"><span class="button-wrap">' + s_Menu + finalString + '</span></a></li>';
  } else if($1) {
    strMenu = '<li><a class="button secondary" href="/' + lang + '/docs/' + $2.replace(/ /g, '_') + '"><span class="button-wrap">' + s_Menu + finalString + '</span></a></li>';
  }
}
%>
<ul class="prev-next">
    <%- strPrevious %>
    <%- strMenu %>
    <%- strNext %>
</ul>
